/**
 入驻小区
 **/
(function (vc) {
    vc.extends({
        propTypes: {
            emitProductNum: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            editProductNumInfo: {
                cateType: '',
                prodName: '',
                specName: '',
                prodPrice: '',
                count: '',
                money: '',
                vipPrice: '',
                flag: '',
                valueId: '',
                productId: '',
                storeId: '',
                shopId: '',
                discountType: '1001',
                discountRate: '1',
                discountPrice: 0
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('editProductNum', 'openEditProductNumModel', function (_param) {
                $('#openEditProductNumModel').modal('show');
                vc.copyObject(_param._stock, $that.editProductNumInfo);
            });
        },
        methods: {
            _closeProductNum: function () {
                vc.emit($props.emitProductNum, 'copeProductNum', $that.editProductNumInfo);
                $('#openEditProductNumModel').modal('hide');
            },
            _closeEditProductNum: function () {
                $('#openEditProductNumModel').modal('hide');
            },
            _editProductNumComputeMoney: function () {
                //单价
                let _price = 0.0;
                if ($that.editProductNumInfo.flag != null && $that.editProductNumInfo.flag != 'undefined' && $that.editProductNumInfo.flag != '' && $that.editProductNumInfo.flag == '1') {
                    _price = $that.editProductNumInfo.vipPrice;
                } else {
                    _price = $that.editProductNumInfo.prodPrice;
                }
                let _count = $that.editProductNumInfo.count;
                let _discountType = $that.editProductNumInfo.discountType;
                let _discountRate = $that.editProductNumInfo.discountRate;
                let _discountPrice = $that.editProductNumInfo.discountPrice;
                //金额
                let _tmpMoney = parseFloat(_price) * parseFloat(_count);
                if (_discountType == '1001') {
                    if (_discountPrice > 1) {
                        vc.toast('打折率请输入0-1 数字');
                        return;
                    }
                    _discountPrice = parseFloat(_tmpMoney) * parseFloat(_discountRate);
                    _discountPrice = parseFloat(_tmpMoney) - _discountPrice;
                }
                $that.editProductNumInfo.discountPrice = parseFloat(_discountPrice).toFixed(2);
                $that.editProductNumInfo.money = (_tmpMoney - parseFloat(_discountPrice)).toFixed(2);
            },
            _clearCashier: function () {
                $that.editProductNumInfo = {
                    cateType: '',
                    prodName: '',
                    specName: '',
                    prodPrice: '',
                    count: '',
                    money: '',
                    vipPrice: '',
                    flag: '',
                    discountType: '1001',
                    discountRate: '1',
                    discountPrice: 0
                }
            }
        }
    });
})(window.vc);
